<%@page import="fun.wlfj.factory.CashSystemFactory"%>
<%@page import="fun.wlfj.vo.Product"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<% String which = "库存管理"; %>
<%@ include file="/header.jsp"%>
<!-- CONTENT -->
<section id="content">
	<div class="page dashboard-page">
		<!-- bradcome -->
		<!-- row -->
		<section class="boxs">
			<div class="boxs-header">
				<h3 class="custom-font hb-blue">
					<strong>库存管理 </strong>
				</h3>

			</div>
			<div class="boxs-body p-0">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>#</th>
							<th>项目ID</th>
							<th>名称</th>
							<th>简称</th>
							<th>库存</th>
							<th>单价</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
					<%
					List<Product> list = CashSystemFactory.getProductDao().getProducts();
					int cnt = 1;
					for(Product p : list){
					%>
						<tr>
							<td><%=cnt ++ %></td>
							<td><%=String.format("PR%06d", p.getProductID()) %></td>
							<td><%=p.getProductName() %></td>
							<td><%=p.getProductShortName() %></td>
							<td><%=p.getProductNums() %></td>
							<td><%=p.getProductPrice() %>¥</td>
							<td><a href="productInfoUpdate?ProductID=<%=p.getProductID() %>"
								class="btn btn-raised btn-info">修改</a></td>
						</tr>
						<%} %>
					</tbody>
				</table>
			</div>
		</section>
		<%
		Product product = (Product)request.getAttribute("ProductModifyInfo");
		if(product != null){
		%>
		<section class="boxs col-md-6">
			<div class="boxs-header">
				<h3 class="custom-font hb-green">
					<strong>库存信息 </strong>修改
				</h3>
			</div>
			<div class="boxs-body">
				<form class="form-horizontal" role="form" action="productInfoUpdate" method="POST">
				<input type="hidden" name="ProductID" value="<%=product.getProductID() %>">
					<div class="form-group">
						<label for="inputProductNameEdit" class="col-sm-2 control-label">名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="inputProductNameEdit" name="ProductName" value="<%=product.getProductName() %>"
								placeholder="输入项目名称">
						</div>
					</div>
					<div class="form-group">
						<label for="inputProductShortNameEdit"
							class="col-sm-2 control-label">简称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control"
								id="inputProductShortNameEdit" placeholder="输入项目简称" name="ProductShortName" value="<%=product.getProductShortName()%>">
						</div>
					</div>
					<div class="form-group">
						<label for="inputProductCountEdit" class="col-sm-2 control-label">库存</label>
						<div class="col-sm-10">
							<input type="number" class="form-control"
								id="inputProductCountEdit" placeholder="输入库存信息" name="ProductNums" value="<%=product.getProductNums() %>">
						</div>
					</div>
					<div class="form-group">
						<label for="inputProductPriceEdit" class="col-sm-2 control-label">单价</label>
						<div class="col-sm-10">
							<input type="text" class="form-control"
								id="inputProductPriceEdit" placeholder="输入项目单价" name="ProductPrice" value="<%=product.getProductPrice() %>">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-raised btn-primary">提交修改</button>
						</div>
					</div>
				</form>
			</div>
		</section>
		<%}else{ %>
		<section class="boxs col-md-6">
			<div class="boxs-header">
				<h3 class="custom-font hb-green">
					<strong>添加收费项目 </strong>
				</h3>
			</div>
			<div class="boxs-body">
				<form class="form-horizontal" role="form" action="productInfoAdd" method="POST">
					<div class="form-group">
						<label for="inputProductNameEdit" class="col-sm-2 control-label">名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="inputProductNameEdit" name="ProductName"
								placeholder="输入项目名称">
						</div>
					</div>
					<div class="form-group">
						<label for="inputProductShortNameEdit"
							class="col-sm-2 control-label">简称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control"
								id="inputProductShortNameEdit" placeholder="输入项目简称" name="ProductShortName">
						</div>
					</div>
					<div class="form-group">
						<label for="inputProductCountEdit" class="col-sm-2 control-label">库存</label>
						<div class="col-sm-10">
							<input type="number" class="form-control"
								id="inputProductCountEdit" placeholder="输入库存信息" name="ProductNums">
						</div>
					</div>
					<div class="form-group">
						<label for="inputProductPriceEdit" class="col-sm-2 control-label">单价</label>
						<div class="col-sm-10">
							<input type="text" class="form-control"
								id="inputProductPriceEdit" placeholder="输入项目单价" name="ProductPrice">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-raised btn-primary">添加</button>
						</div>
					</div>
				</form>
			</div>
		</section>
		
		<%} %>
	</div>
</section>
<%@ include file="/footer.jsp"%>